<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
       
    </style>

</head>
<body>
   <span id="span1">1</span>
   <ul id="main">
       <!-- 我是注释 -->
       <li>选择珠峰的，都是明智的！</li>
       <li>选择珠峰的，都是明智的！</li>
       <li>选择珠峰的，都是明智的！</li>
       <li>选择珠峰的，都是明智的！</li>
   </ul>
   <span id="span2">2</span>
</body>
</html>
<script>
//previousElmentSibling 必须是标签 
 function previousElmentSibling(ele){
     var pre=ele.previousSibling;
     //1.有 2.不是标签
     while(pre&&pre.nodeType!==1){
        pre=pre.previousSibling;
     }
     return pre;//如果是标签，就不进入循环
 }
console.log(previousElmentSibling(span2))
</script>
